import { request } from '@/utils/request'
import type {
  GETPatientOrderIdLogisticsRes,
  MedicineOrderDetail,
  MedicineOrderPre,
} from '@/types/order'

// 获取药品订单预支付信息
export const getMedicineOrderPreAPI = (params: {
  prescriptionId: string
  couponId?: string
  useCoupon?: string
}) => {
  return request<MedicineOrderPre>('/patient/medicine/order/pre', 'GET', params)
}

// 根据处方下药品订单
export const createMedicineOrderAPI = (data: {
  id: string
  addressId: string
  couponId?: string
}) => {
  return request<{ id: string }>('/patient/medicine/order', 'POST', data)
}

// 获取药品订单详情
export const getMedicineOrderDetailAPI = (id: string) => {
  return request<MedicineOrderDetail>(`/patient/medicine/order/detail/${id}`, 'GET')
}

// 订单-删除订单
export const DeletePatientOrderAPI = (id: string) => {
  return request(`/patient/order/${id}`, 'DELETE')
}

// 订单-取消订单  PUT/patient/order/cancel/{id}
export const PutCancelPatientOrderAPI = (id: string) => {
  return request(`/patient/order/cancel/${id}`, 'PUT')
}

// 订单-查询物流信息  GET/patient/order/{id}/logistics
export const GetPatientOrderIdLogisticsAPI = (id: string) => {
  return request<GETPatientOrderIdLogisticsRes>(`/patient/order/${id}/logistics`, 'GET')
}
